package com.eh.command.controller.ext;

import com.eh.command.command.Command;

/**
 * Created by David on 2016/4/30.
 */
public class Slot {
    private boolean used;
    private String commandName;
    private Command command;

    public Slot() {
        used = false;
    }

    public void pressed() {
        if (isUsed()) {
            command.execute();
        }
    }

    public void bind(Command command) {
        this.command = command;
        commandName = command.toString();
        used = true;
    }

    public String getCommandName() {
        return commandName;
    }

    public void clear() {
        command = null;
        used = false;
    }

    public boolean isUsed() {
        return used;
    }
}
